//package com.plian.system.controller.om;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.plian.Tools.TokenUtil;
//import com.plian.Tools.base.BaseController;
//import com.plian.system.entity.om.FillPointsRecord;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.ObjResult;
//import com.plian.system.service.om.IFillPointsRecordService;
//import com.plian.system.service.om.module.IModuleConfigService;
//import com.plian.system.service.sys.orgzation.OrgzationService;
//import com.plian.system.vo.om.FillAssessmentVO;
//import com.plian.system.vo.om.FillPointsRecordVO;
//import com.plian.system.wrapper.om.FillPointsRecordWrapper;
//import lombok.AllArgsConstructor;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.List;
//import java.util.Optional;
//
///**
// * @author panqb
// * @version 1.0
// * @description:扣分记录控制器
// * @date 2022/3/28 下午4:16
// */
//@RestController
//@AllArgsConstructor
//@RequestMapping("api/fillpointsrecord")
//public class FillPointsRecordController extends BaseController {
//
//    private IFillPointsRecordService fillPointsRecordService;
//
//    private FillPointsRecordWrapper fillPointsRecordWrapper;
//
//    private OrgzationService orgzationService;
//
//    private IModuleConfigService moduleConfigService;
//
//    @PostMapping("save")
//    public ObjResult save(@RequestBody FillPointsRecord fillPointsRecord){
//        ObjResult objResult=new ObjResult(CommonCode.SUCCESS);
//        String orgName=orgzationService.getNameById(TokenUtil.getTokenOrgId());
//        fillPointsRecord.setDeductScoreDept(orgName);
//        return fillPointsRecordService.save(fillPointsRecord)?objResult:new ObjResult(CommonCode.FAIL);
//    }
//
//    /**
//     * 根据单位机构id和对应月份获取扣分明细列表
//     * @param fillPointsRecord
//     * @return
//     */
//    @PostMapping("listByOrgAndMonth")
//    public ListResult<FillPointsRecordVO> listByOrgAndMonth(@RequestBody  FillPointsRecord fillPointsRecord){
//        String orgId=fillPointsRecord.getOrgId();
//        if(!Optional.ofNullable(orgId).isPresent()){
//            orgId= TokenUtil.getTokenOrgId();
//        }
//        QueryWrapper queryWrapper=new QueryWrapper();
//        queryWrapper.eq("org_id",orgId);
//        queryWrapper.eq("check_month",fillPointsRecord.getCheckMonth());
//        queryWrapper.orderByDesc("create_time");
//        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
//        ListResult<FillPointsRecordVO> listResult=new ListResult<>(CommonCode.SUCCESS);
//        List<FillPointsRecord> list=fillPointsRecordService.list(queryWrapper);
//        List<FillPointsRecordVO> recordVOS=fillPointsRecordWrapper.entityToVO(list);
//        recordVOS.forEach(record->{
//            record.setScore(-1*record.getScore());
//            String type=record.getType();
//            Date updateTime=record.getUpdateTime();
//            record.setUpdateTimeShort(sdf.format(updateTime));
//            switch (type){
//                case "1":
//                    record.setTypeName("准确性");
//                    break;
//                case "2":
//                    record.setTypeName("及时性");
//                    break;
//                case "3":
//                    record.setTypeName("完整性");
//                    break;
//            }
//        });
//        listResult.setTotal(recordVOS.size());
//        listResult.setList(recordVOS);
//        return listResult;
//    }
//
//    /**
//     * 单位扣分明细
//     * @param fillPointsRecord
//     * @return
//     */
//    @PostMapping("scoreOrgList")
//    public ListResult<FillAssessmentVO> scoreOrgList(@RequestBody  FillPointsRecord fillPointsRecord){
//       ListResult<FillAssessmentVO> result=new ListResult<>(CommonCode.SUCCESS);
//       List<FillAssessmentVO> fillAssessmentVOList=fillPointsRecordService.getDeductScoreOrgList(fillPointsRecord);
//       result.setTotal(fillAssessmentVOList.size());
//       result.setList(fillAssessmentVOList);
//       return  result;
//    }
//}
